home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcr / pcr4_4.lha / DIST / gc / GCptr_test.c < prev    next >
C/C++ Source or Header  |  1990-11-30  |  1KB  |  38 lines

  1.  
  2. # include <xr/GC.h>
  3. # include <xr/GCPrivate.h>
  4.  
  5. /* If p is a valid pointer to an object, return a pointer to the */
  6. /* beginning of that object.  Otherwise return NIL.         */
  7. /* If szp is nonNIL, save the objects size in bytes in *szp.     */
  8. /* If ptrfreep is nonNIL, set *ptrfreep to 0 or 1 depending on   */
  9. /* whether or not the object is pointer free.             */
  10. /* An object may be considered valid even though it is about to  */
  11. /* be garbage collected because it was inaccessible during the   */
  12. /* last mark phase.  A nonNIL result does guarantee that the     */
  13. /* object can be read without generating a fault.                */
  14. XR_Pointer XR_PtrTest(p, szp, ptrfreep)
  15. struct obj * p;  /* May be any 32 bit integer */
  16. long * szp;
  17. int * ptrfreep;
  18. {
  19.     struct hblk * h;
  20.     int word_no;
  21.     long sz;
  22.     bool is_atomic;
  23.     
  24. #   ifdef SEPARATE_HEADERS
  25.       register struct hblkhdr * hhdr;
  26. #   endif
  27.  
  28.     if (!quicktest(p)) return(0);
  29.     
  30. #   define CONTINUE return(0)
  31. #   define CONTINUE_M ;
  32. #     include "GCcheck_ptr.c"
  33. #   undef CONTINUE_M
  34. #   undef CONTINUE
  35.     if (szp) *szp = WORDS_TO_BYTES(sz);
  36.     if (ptrfreep) *ptrfreep = is_atomic;
  37.     return ((XR_Pointer)(((word *)h) + word_no));
  38. }